package com.lanchetech.user.controller;

import com.lanchetech.bean.request.*;
import com.lanchetech.bean.response.*;
import com.lanchetech.bean.vo.*;
import com.lanchetech.common.exception.ResultCodeException;
import com.lanchetech.entity.*;
import com.lanchetech.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

@Api(value = "用户信息接口", tags = "用户信息接口")
@RequestMapping("/api/user")
@RestController
public class UserController {

    @Autowired
    UserService userService;

    @ApiOperation("获取用户详细信息")
    @GetMapping("/getUserDetail")
    public ResultData<UserDetailResp> getUserDetail(@AuthenticationPrincipal User user) {
        return userService.getUserDetail(user);
    }

    @ApiOperation("获取用户个人信息")
    @GetMapping("/getUserInfo")
    public ResultData<UserInfo> getUserInfo(@AuthenticationPrincipal User user) {
        return userService.getUserInfo(user);
    }

    @ApiOperation("修改用户头像")
    @GetMapping("/updateAvatar")
    public BaseResp updateAvatar(@AuthenticationPrincipal User user, @RequestParam("avatar") String avatar) {
        return userService.updateAvatar(user, avatar);
    }

    @ApiOperation("修改用户昵称")
    @GetMapping("/updateUserNickname")
    public BaseResp updateUserNickname(@AuthenticationPrincipal User user, @RequestParam("nickname") String nickname) {
        return userService.updateNickname(user, nickname);
    }

    @ApiOperation("修改用户手机号")
    @GetMapping("/updateUserPhone")
    public BaseResp updateUserPhone(@AuthenticationPrincipal User user, @RequestParam("phone") String phone, @RequestParam("code") String code) {
        return userService.updatePhone(user, phone, code);
    }

    @ApiOperation(value = "重新绑定微信")
    @PostMapping("/rebindWechat")
    public BaseResp rebindWechat(@AuthenticationPrincipal User user, @RequestBody RegisterReq req) {
        return userService.rebindWechat(user, req);
    }

    @ApiOperation("获取用户地址")
    @GetMapping("/getUserAddress")
    public ResultData<UserAddress> getUserAddress(@AuthenticationPrincipal User user, @RequestParam("id") Long id) {
        return userService.getUserAddress(user, id);
    }

    @ApiOperation("获取用户地址列表")
    @GetMapping("/getUserAddressList")
    public ResultData<List<UserAddress>> getUserAddressList(@AuthenticationPrincipal User user) {
        return userService.getUserAddressList(user);
    }

    @ApiOperation("添加或编辑用户地址")
    @PostMapping("/editUserAddress")
    public BaseResp editUserAddress(@AuthenticationPrincipal User user, @RequestBody UserAddress userAddress) {
        return userService.editUserAddress(user, userAddress);
    }

    @ApiOperation("删除用户地址")
    @GetMapping("/deleteUserAddress")
    public BaseResp deleteUserAddress(@AuthenticationPrincipal User user, @RequestParam("id") Long id) {
        return userService.deleteUserAddress(user, id);
    }

    @ApiOperation("获取用户主要地址")
    @GetMapping("/getMainUserAddress")
    public ResultData<UserAddress> getMainUserAddress(@AuthenticationPrincipal User user) {
        return userService.getMainUserAddress(user);
    }

    @ApiOperation("获取用户的下级分页")
    @PostMapping("/getUserSubordinatePage")
    public ResultData<BasePageResp<RelationshipResp>> getUserSubordinatePage(@AuthenticationPrincipal User user, @RequestBody RelationshipReq req) {
        return userService.getUserSubordinatePage(user, req);
    }


    @ApiOperation("变更用户上下级关系")
    @GetMapping("/changeUserRelationship")
    public BaseResp changeUserRelationship(@AuthenticationPrincipal User user, @RequestParam("inviteCode") String inviteCode) {
        return userService.changeUserRelationship(user, inviteCode);
    }


    @ApiOperation("修改用户身份证号和真实姓名")
    @PostMapping("/updateUserIdCardAndRealName")
    public BaseResp updateUserIdCardAndRealName(@AuthenticationPrincipal User user, @RequestBody UserInfo userInfo) {
        return userService.updateUserIdCardAndRealName(user, userInfo);
    }

    @ApiOperation(value = "获取用户邀请海报二维码")
    @PostMapping("/getInviteQrcode")
    public ResultData<String> getInviteQrcode(@AuthenticationPrincipal User user) {
        return userService.getInviteQrcode(user);
    }

    @ApiOperation(value = "获取老板邀请海报二维码")
    @PostMapping("/getBossInviteQrcode")
    public ResultData<String> getBossInviteQrcode(@AuthenticationPrincipal User user) {
        return userService.getBossInviteQrcode(user);
    }

    @ApiOperation(value = "获取达人邀请海报二维码")
    @PostMapping("/getExpertInviteQrcode")
    public ResultData<String> getExpertInviteQrcode(@AuthenticationPrincipal User user) {
        return userService.getExpertInviteQrcode(user);
    }

    @ApiOperation("获取用户我的页面统计信息")
    @GetMapping("/getMineStatistics")
    public ResultData<MineDetailVO> getMineStatistics(@AuthenticationPrincipal User user) {
        return userService.getMineStatistics(user);
    }

    @ApiOperation("添加我的足迹")
    @GetMapping("/createTracks")
    public BaseResp createTracks(@AuthenticationPrincipal User user, @RequestParam("spuId") Long spuId) {
        return userService.createTracks(user, spuId);
    }

    @ApiOperation("删除我的足迹")
    @GetMapping("/deleteTracks")
    public BaseResp deleteTracks(@AuthenticationPrincipal User user, @RequestParam("id") Long id) {
        return userService.deleteTracks(user, id);
    }

    @ApiOperation("添加我的收藏")
    @GetMapping("/createCollection")
    public ResultData<UserCollection> createCollection(@AuthenticationPrincipal User user, @RequestParam("spuId") Long spuId) {
        return userService.createCollection(user, spuId);
    }

    @ApiOperation("取消我的收藏")
    @GetMapping("/deleteCollection")
    public BaseResp deleteCollection(@AuthenticationPrincipal User user, @RequestParam("id") Long id) {
        return userService.deleteCollection(user, id);
    }

    @ApiOperation("判断商品是否已经收藏")
    @GetMapping("/getCollection")
    public ResultData<UserCollection> getCollection(@AuthenticationPrincipal User user, @RequestParam("spuId") Long spuId) {
        return userService.getCollection(user, spuId);
    }

    @ApiOperation("获取用户收藏的商品列表")
    @PostMapping("/getCollectionPage")
    public ResultData<BasePageResp<CollectionResp>> getCollectionPage(@AuthenticationPrincipal User user, @RequestBody PageReq req) {
        return userService.getCollectionPage(user, req);
    }

    @ApiOperation("获取搜索历史")
    @GetMapping("/getSearchHistory")
    public ResultData<List<SearchHistory>> getSearchHistory(@AuthenticationPrincipal User user) {
        return userService.getSearchHistory(user);
    }

    @ApiOperation("添加搜索历史")
    @PostMapping("/createSearchHistory")
    public BaseResp createSearchHistory(@AuthenticationPrincipal User user, @RequestBody SearchHistory searchHistory) {
        return userService.createSearchHistory(user, searchHistory);
    }

    @ApiOperation("清空搜索历史")
    @GetMapping("/clearSearchHistory")
    public BaseResp clearSearchHistory(@AuthenticationPrincipal User user) {
        return userService.clearSearchHistory(user);
    }

    @ApiOperation("获取用户足迹列表")
    @PostMapping("/getTracksPage")
    public ResultData<BasePageResp<TracksResp>> getTracksPage(@AuthenticationPrincipal User user, @RequestBody PageReq req) {
        return userService.getTracksPage(user, req);
    }


    @ApiOperation("获取用户佣金收入分页")
    @PostMapping("/getCommissionPage")
    public ResultData<BasePageResp<UserCommissionResp>> getCommissionPage(@AuthenticationPrincipal User user, @RequestBody UserCommissionReq req) {
        return userService.getCommissionPage(user, req);
    }

    @ApiOperation("获取运营中心详情")
    @PostMapping("/getShareholderDetail")
    public ResultData<ShareholderVO> getShareholderDetail(@AuthenticationPrincipal User user) {
        return userService.getShareholderDetail(user);
    }

    @ApiOperation("获取会员和合伙人收入")
    @PostMapping("/getMemberAndPartnerIncome")
    public ResultData<List<IncomeVO>> getMemberAndPartnerIncome(@AuthenticationPrincipal User user, @RequestBody UserGroupReq req) {
        return userService.getMemberAndPartnerIncome(user, req);
    }

    @ApiOperation("获取用户优惠券分页")
    @PostMapping("/getUserCouponPage")
    public ResultData<BasePageResp<Coupon>> getUserCouponPage(@AuthenticationPrincipal User user, @RequestBody PageReq req) {
        return userService.getUserCouponPage(user, req);
    }

    @ApiOperation("获取用户优惠券详情")
    @GetMapping("/getUserCouponDetail")
    public ResultData<Coupon> getUserCouponDetail(@RequestParam("id") Long id) {
        return userService.getUserCouponDetail(id);
    }

    @ApiOperation(value = "获取用户身份绑定码")
    @PostMapping("/getStaffCode")
    public ResultData<String> getStaffCode(@AuthenticationPrincipal User user) {
        return userService.getStaffCode(user);
    }

    @ApiOperation(value = "编辑我的名片")
    @PostMapping("/editBusinessCard")
    public BaseResp editBusinessCard(@RequestBody BusinessCard req) {
        return userService.editBusinessCard(req);
    }

    @ApiOperation("获取我的名片")
    @GetMapping("/getMyBusinessCard")
    public ResultData<BusinessCardVO> getMyBusinessCard(@RequestParam(value = "userId") Long userId) {
        return userService.getMyBusinessCard(userId);
    }

    @ApiOperation(value = "用户注销")
    @GetMapping("/closeUser")
    public BaseResp closeUser(@AuthenticationPrincipal User user) {
        return userService.closeUser(user);
    }

    @ApiOperation("获取我的团队分页")
    @PostMapping("/getUserGroupPage")
    public ResultData<BasePageResp<UserGroupVO>> getUserGroupPage(@AuthenticationPrincipal User user, @RequestBody UserGroupReq req) {
        return userService.getUserGroupPage(user, req);
    }

    @ApiOperation("获取我的嗨币流水分页")
    @PostMapping("/getCardFlowPage")
    public ResultData<BasePageResp<CardFlowVO>> getCardFlowPage(@AuthenticationPrincipal User user, @RequestBody PageReq req) {
        return userService.getCardFlowPage(user, req);
    }

    @ApiOperation("获取用户的身份信息")
    @GetMapping("/getUserIdentity")
    public ResultData<IdentityResp> getUserIdentity(@AuthenticationPrincipal User user) {
        return userService.getUserIdentity(user);
    }

    @ApiOperation("获取我的团队数据")
    @PostMapping("/getUserGroup")
    public ResultData<GroupVO> getUserGroup(@AuthenticationPrincipal User user, @RequestBody ListByTimeReq req) {
        return userService.getUserGroup(user, req);
    }

    @ApiOperation("获取用户的钱包（冻结佣金总额、佣金余额、已提现金额、待处理提现总金额）")
    @GetMapping("/getUserMoneyInfo")
    public ResultData<MoneyInfoResp> getUserMoneyInfo(@AuthenticationPrincipal User user, @RequestParam("businessType") Byte businessType) {
        return userService.getUserMoneyInfo(user, businessType);
    }

    @ApiOperation("获取我的钱包收支近6月")
    @GetMapping("/getUserMoneyStatistics")
    public ResultData<List<UserMoneyStatisticsVO>> getUserMoneyStatistics(@AuthenticationPrincipal User user) {
        return userService.getUserMoneyStatistics(user);
    }

    @ApiOperation("获取用户分红收益")
    @GetMapping("/getUserBonusInfo")
    public ResultData<IncomeInfoVO> getUserBonusInfo(@AuthenticationPrincipal User user) {
        return userService.getUserBonusInfo(user);
    }

    @ApiOperation("获取用户直推收益")
    @GetMapping("/getUserDistributionInfo")
    public ResultData<IncomeInfoVO> getUserDistributionInfo(@AuthenticationPrincipal User user) {
        return userService.getUserDistributionInfo(user);
    }

    @ApiOperation("获取用户分红和直推收益明细统计")
    @PostMapping("/getIncomeCount")
    public ResultData<IncomeDetailVO> getIncomeCount(@AuthenticationPrincipal User user, @RequestBody ListByTimeReq req) {
        return userService.getIncomeCount(user, req);
    }

    @ApiOperation("获取自动免单")
    @GetMapping("/getAutomaticFree")
    public ResultData<AutomaticFreeListVO> getAutomaticFree(@RequestParam("level") Integer level) {
        return userService.getAutomaticFree(level);
    }

    @ApiOperation("获取等待免单")
    @GetMapping("/getWaitFree")
    public ResultData<WaitFreeVO> getWaitFree(@AuthenticationPrincipal User user, @RequestParam("level") Integer level) {
        return userService.getWaitFree(user, level);
    }

    @ApiOperation("添加联系我们的用户信息")
    @PostMapping("/createInformation")
    public BaseResp createInformation(@RequestBody Information information) {
        return userService.createInformation(information);
    }

    @ApiOperation("添加或修改商圈合作")
    @PostMapping("/editShopApply")
    public BaseResp createInformation(@AuthenticationPrincipal User user,
                                      @RequestBody Shop shop) {
        return userService.editShopApply(user, shop);
    }

    @ApiOperation("获取我的商圈合作")
    @GetMapping("/getShopApply")
    public ResultData<ShopApply> getShopApply(@AuthenticationPrincipal User user) {
        return userService.getShopApply(user);
    }

    @ApiOperation("获取我的积分统计")
    @GetMapping("/getCoinCount")
    public ResultData<CoinCountVO> getCoinCount(@AuthenticationPrincipal User user) {
        return userService.getCoinCount(user);
    }

    @ApiOperation("获取用户余额收益统计")
    @PostMapping("/getBalanceFlowCount")
    public ResultData<CountVO> getBalanceFlowCount(@RequestBody TimeTypeReq req) {
        return userService.getBalanceFlowCount(req);
    }

    @ApiOperation("获取嗨币明细统计")
    @PostMapping("/getCardFlowStatistics")
    public ResultData<CardFlowStatisticsVO> getCardFlowStatistics(@RequestBody TimeTypeReq req) {
        return userService.getCardFlowStatistics(req);
    }

    @ApiOperation("获取嗨跑收支记录排行")
    @PostMapping("/getCardFlowRecordRank")
    public ResultData<List<CardFlow>> getCardFlowRecordRank(@RequestBody TimeTypeReq req) {
        return userService.getCardFlowRecordRank(req);
    }

    @ApiOperation("获取嗨跑收支近六月统计")
    @GetMapping("/getCardFlowCurrentMonth")
    public ResultData<List<StatisticsVO>> getCardFlowCurrentMonth(@RequestParam("type") Byte type) {
        return userService.getCardFlowCurrentMonth(type);
    }

    @ApiOperation("获取用户余额流水")
    @PostMapping("/getBalanceFlowPage")
    public ResultData<BasePageResp<BalanceFlow>> getBalanceFlowPage(@RequestBody TimeTypeReq req) {
        return userService.getBalanceFlowPage(req);
    }

    @ApiOperation("获取用户收支流水统计近6月")
    @GetMapping("/getBalanceFlowStatistics")
    public ResultData<List<BalanceFlowStatisticsVO>> getBalanceFlowStatistics(@RequestParam("type") Byte type) {
        return userService.getBalanceFlowStatistics(type);
    }

    @ApiOperation("获取用户收支笔数和金额")
    @PostMapping("/getBalanceFlowCountAndMoney")
    public ResultData<BalanceFlowCountAndMoneyVO> getBalanceFlowCountAndMoney(@RequestBody TimeTypeReq req) {
        return userService.getBalanceFlowCountAndMoney(req);
    }

    @ApiOperation("获取经营品类")
    @GetMapping("/getCatalogList")
    public ResultData<List<Catalog>> getCatalogList() {
        return userService.getCatalogList();
    }


    @ApiOperation("获取直推佣金收入")
    @GetMapping("/getUserCommission")
    public ResultData<List<DirectPushIncomeVO>> getUserCommission(@AuthenticationPrincipal User user) {
        return userService.getUserCommission(user);
    }

    @ApiOperation("获取直推明细通过时间类型")
    @PostMapping("/getUserCommissionDetailByTimeType")
    public ResultData<BasePageResp<DirectPushIncomeVO>> getUserCommissionDetailByTimeType(@RequestBody UserCommissionReq req) {
        return userService.getUserCommissionDetailByTimeType(req);
    }

    @ApiOperation("获取直推佣金全部收入")
    @GetMapping("/getTotalUserCommission")
    public ResultData<DirectPushIncomeVO> getTotalUserCommission(@AuthenticationPrincipal User user) {
        return userService.getTotalUserCommission(user);
    }

    @ApiOperation("获取直推佣金变化情况")
    @GetMapping("/getUserCommissionChange")
    public ResultData<IncomeTimeVO> getUserCommissionChange(@AuthenticationPrincipal User user) {
        return userService.getUserCommissionChange(user);
    }

    @ApiOperation("获取上周月全国冠军")
    @GetMapping("/getChampionByRankType")
    public ResultData<List<RankNicknamePerformanceVO>> getChampionByRankType(@RequestParam("identityType") Byte identityType) {
        return userService.getChampionByRankType(identityType);
    }

    @ApiOperation("获取排行")
    @PostMapping("/getRankByType")
    public ResultData<List<RankNicknamePerformanceVO>> getRankByType(@RequestBody TimeTypeReq req) {
        return userService.getRankByType(req);
    }

    @ApiOperation("获取总排行")
    @GetMapping("/getUserCommissionRank")
    public ResultData<List<RankNicknamePerformanceVO>> getUserCommissionRank(@RequestParam("identityType") Byte identityType) {
        return userService.getUserCommissionRank(identityType);
    }


    @ApiOperation("区域代理收益明细通过时间范围")
    @PostMapping("/getAgentCommissionDetailByTimeType")
    public ResultData<BasePageResp<AgentCommissionTotalVO>> getAgentCommissionDetailByTimeType(@RequestBody AgentCommissionDetailReq req) {
        return userService.getAgentCommissionDetailByTimeType(req);
    }

    @ApiOperation("区域代理收入总额")
    @GetMapping("/getTotalUserAgentCommission")
    public ResultData<UserAgentCommissionTotalVO> getTotalUserAgentCommission(@AuthenticationPrincipal User user, @RequestParam("type") Byte type) {
        return userService.getTotalUserAgentCommission(user, type);
    }

    @ApiOperation("获取商家钱包收入统计")
    @PostMapping("/getIncomeStatistics")
    public ResultData<List<IncomeStatisticVo>> getIncomeStatistics(@RequestBody IncomeStatisticReq incomeStatisticReq) {
        return userService.getIncomeStatistics(incomeStatisticReq);
    }

    @ApiOperation("获取商家钱包收入统计近6月")
    @GetMapping("/getIncomeStatisticsMonth")
    public ResultData<List<IncomeStatisticVo>> getIncomeStatisticsMonth(@AuthenticationPrincipal User user) {
        return userService.getIncomeStatisticsMonth(user);
    }


    @ApiOperation("获取商家订单数据统计")
    @GetMapping("/getOrderStatistics")
    public ResultData<List<OrderStatisticVO>> getOrderStatistics(@AuthenticationPrincipal User user, @RequestParam("timeType") Byte timeType) {
        return userService.getOrderStatistics(user, timeType);
    }

    @ApiOperation("获取免单和购买用户")
    @GetMapping("/getRewardQueue")
    public ResultData<List<RewardQueueVO>> getRewardQueue(@AuthenticationPrincipal User user) {
        return userService.getRewardQueue(user);
    }

    @ApiOperation("获取我的免单记录分页")
    @PostMapping("/getMyRewardQueuePage")
    public ResultData<BasePageResp<RewardQueueVO>> getMyRewardQueuePage(@AuthenticationPrincipal User user, @RequestBody RewardQueuePageReq req) {
        return userService.getMyRewardQueuePage(user, req);
    }

    @ApiOperation("开启关闭免单播报")
    @GetMapping("/editVoiceSet")
    public BaseResp editVoiceSet(@AuthenticationPrincipal User user) {
        return userService.editVoiceSet(user);
    }


    @ApiOperation("查询是否已经收听过最新的免单播报")
    @GetMapping("/getLastRewardQueueAudio")
    public ResultData<RewardQueue> getLastRewardQueueAudio(@AuthenticationPrincipal User user) {
        return userService.getLastRewardQueueAudio(user);
    }

    @ApiOperation("获取我的团队")
    @GetMapping("/getUserGroupByIdentityType")
    public ResultData<List<UserGroupCommissionVO>> getUserGroupByIdentityType(@RequestParam("identityType") Byte identityType) {
        return userService.getUserGroupByIdentityType(identityType);
    }

    @ApiOperation("获取我的团队成员")
    @PostMapping("/getUserGroupMemberByMemberType")
    public ResultData<BasePageResp<UserGroupListVO>> getUserGroupMemberByMemberType(@RequestBody MemberTypeReq req) {
        return userService.getUserGroupMemberByMemberType(req);
    }

    @ApiOperation("获取团长信息")
    @GetMapping("/getUserGroupCaptainDetail")
    public ResultData<UserGroupCaptainDetailVO> getUserGroupCaptainDetail(@AuthenticationPrincipal User user) {
        return userService.getUserGroupCaptainDetail(user);
    }

    @ApiOperation("获取团员名片")
    @GetMapping("/getUserGroupMemberBusinessCard")
    public ResultData<BusinessCardVO> getUserGroupMemberBusinessCard(@RequestParam("userId") Long userId) {
        return userService.getUserGroupMemberBusinessCard(userId);
    }

    @ApiOperation("获取晋级身份晋级次数")
    @GetMapping("/getUserPromotionIdentity")
    public ResultData<Identity> getUserPromotionIdentity(@AuthenticationPrincipal User user) {
        return userService.getUserPromotionIdentity(user);
    }

    @ApiOperation("获取直推人数统计")
    @GetMapping("/getUserDirectPushNumberStatistics")
    public ResultData<List<UserDirectPushStatisticsVO>> getUserDirectPushNumberStatistics(@AuthenticationPrincipal User user) {
        return userService.getUserDirectPushNumberStatistics(user);
    }


    @ApiOperation("获取晋级分红和全国业绩")
    @GetMapping("/getPromotionIncomeAndTotalAmount")
    public ResultData<List<PromotionIncomeAndTotalAmountVO>> getPromotionIncomeAndTotalAmount(@AuthenticationPrincipal User user) {
        return userService.getPromotionIncomeAndTotalAmount(user);
    }

    @ApiOperation("获取晋级分红每月统计")
    @GetMapping("/getPromotionIncomeStatistics")
    public ResultData<List<PromotionIncomeStatisticsVO>> getPromotionIncomeStatistics(@AuthenticationPrincipal User user) {
        return userService.getPromotionIncomeStatistics(user);
    }

    @ApiOperation("获取晋级身份配置值")
    @GetMapping("/getPromotionIdentityValue")
    public ResultData<List<HipoConfig>> getPromotionIdentityValue(@AuthenticationPrincipal User user) {
        return userService.getPromotionIdentityValue(user);
    }

    @ApiOperation("获取平均分红统计")
    @GetMapping("/getAvgPromotionIncome")
    public ResultData<List<AvgPromotionIncomeVO>> getAvgPromotionIncome(@AuthenticationPrincipal User user) {
        return userService.getAvgPromotionIncome(user);
    }

    @ApiOperation("获取累计收益变化")
    @GetMapping("/getPromotionIncomeChange")
    public ResultData<List<IncomeTimeVO>> getPromotionIncomeChange(@AuthenticationPrincipal User user) {
        return userService.getPromotionIncomeChange(user);
    }

    @ApiOperation("获取晋级奖励信息")
    @GetMapping("/getPromotionAwardDetail")
    public ResultData<PromotionAwardDetailVO> getPromotionAwardDetail(@AuthenticationPrincipal User user, @RequestParam("type") Byte type) {
        return userService.getPromotionAwardDetail(user, type);
    }

    @ApiOperation("获取历史奖励")
    @GetMapping("/getHistoryAward")
    public ResultData<List<HistoryAwardVO>> getHistoryAward(@AuthenticationPrincipal User user, @RequestParam("type") Byte type) {
        return userService.getHistoryAward(user, type);
    }

    @ApiOperation("获取排单信息")
    @GetMapping("/getRewardQueueLately")
    public ResultData<List<RewardQueueLatelyVO>> getRewardQueueLately(@AuthenticationPrincipal User user, @RequestParam("type") Byte type) {
        return userService.getRewardQueueLately(user, type);
    }

    @ApiOperation("收藏商家")
    @PostMapping("/addShopCollection")
    public BaseResp addShopCollection(@RequestBody ShopCollection shopCollection) {
        return userService.addShopCollection(shopCollection);
    }

    @ApiOperation("删除收藏商家")
    @GetMapping("/deleteShopCollection")
    public BaseResp deleteShopCollection(@RequestParam("shopId") Long shopId) {
        return userService.deleteShopCollection(shopId);
    }

    @ApiOperation("获取收藏商家分页")
    @PostMapping("/getShopCollectionPage")
    public ResultData<BasePageResp<ShopCollectionVO>> getShopCollectionPage(@RequestBody PageReq req) {
        return userService.getShopCollectionPage(req);
    }

    @ApiOperation("获取我的钱包各类金额")
    @PostMapping("/getMyCommission")
    public ResultData<List<CommissionByTypeVO>> getMyCommission(@AuthenticationPrincipal User user) {
        return userService.getMyCommission(user);
    }

    @ApiOperation("获取推荐商家收入信息")
    @GetMapping("/getRecommendShop")
    public ResultData<RecommendShopVO> getRecommendShop(@AuthenticationPrincipal User user) {
        return userService.getRecommendShop(user);
    }

    @ApiOperation("获取我的直推商家列表")
    @GetMapping("/getMyDirectPushShopList")
    public ResultData<List<MyDirectPushShopVO>> getMyDirectPushShopList(@AuthenticationPrincipal User user) {
        return userService.getMyDirectPushShopList(user);
    }

    @ApiOperation("获取免单和未免单金额")
    @GetMapping("/getFreeOrderMoney")
    public ResultData<FreeOrderMoneyVO> getFreeOrderMoney(@AuthenticationPrincipal User user, @RequestParam(value = "rewardType", required = false) Byte rewardType) {
        return userService.getFreeOrderMoney(user, rewardType);
    }

    @ApiOperation("获取免单或非免单分页")
    @PostMapping("/getFreeOrderPage")
    public ResultData<BasePageResp<FreeOrderListVO>> getFreeOrderPage(@RequestBody PageReq req) {
        return userService.getFreeOrderPage(req);
    }

    @ApiOperation("获取指定类型的佣金总和")
    @GetMapping("/sumOfCommissionByType")
    public ResultData<BigDecimal> sumOfCommissionByType(@AuthenticationPrincipal User user, @RequestParam("type") Byte type) {
        return userService.sumOfCommissionByType(user, type);
    }

    @ApiOperation("获取合伙人排行")
    @PostMapping("/getPartnerRank")
    public ResultData<List<PartnerRankVO>> getPartnerRank(@RequestBody PartnerRankReq req) {
        return userService.getPartnerRank(req);
    }

    @ApiOperation("判断是否为店长或老板")
    @GetMapping("/isBossOrOwner")
    public ResultData<Boolean> isBossOrOwner() {
        return userService.isBossOrOwner();
    }

    @ApiOperation("获取区域申请情况")
    @GetMapping("/getAreaApplyList")
    public ResultData<AreaApplyAreaVO> getAreaApplyList(@RequestParam("city") Long city) {
        return userService.getAreaApplyList(city);
    }

    @ApiOperation("编辑区域代理申请")
    @PostMapping("/editAreaApply")
    public BaseResp editAreaApply(@RequestBody AreaApplyReq req) {
        return userService.editAreaApply(req);
    }

    @ApiOperation("获取区域代理申请分页")
    @PostMapping("/getAreaApplyPage")
    public ResultData<BasePageResp<AreaApplyVO>> getAreaApplyPage(@RequestBody AreaApplyPageReq req) {
        return userService.getAreaApplyPage(req);
    }

    @ApiOperation("取消区域代理申请")
    @GetMapping("/cancelAreaApply")
    public BaseResp cancelAreaApply(@RequestParam("id") Long id) {
        return userService.cancelAreaApply(id);
    }

    @ApiOperation("删除区域代理申请")
    @GetMapping("/deleteAreaApply")
    public BaseResp deleteAreaApply(@RequestParam("id") Long id) {
        return userService.deleteAreaApply(id);
    }


    @ApiOperation("获取区域审核详情")
    @GetMapping("/getAreaApplyDetail")
    public ResultData<AreaApplyVO> getAreaApplyDetail(@RequestParam("id") Long id) {
        return userService.getAreaApplyDetail(id);
    }

    @ApiOperation(value = "意见反馈")
    @PostMapping("/editSuggestion")
    public BaseResp editSuggestion(@RequestBody Suggestion req) {
        return userService.editSuggestion(req);
    }

    @ApiOperation("获取日分红记录分页")
    @PostMapping("/getDayCommissionPage")
    public ResultData<BasePageResp<DayCommissionVO>> getDayCommissionPage(@RequestBody PageReq req) {
        return userService.getDayCommissionPage(req);
    }

    @ApiOperation("获取分红记录")
    @PostMapping("/getOrderSkuByTimeTypePage")
    public ResultData<BasePageResp<StatisticsVO>> getOrderSkuByTimeTypePage(@RequestBody TimeTypeReq req) {
        return userService.getOrderSkuByTimeTypePage(req);
    }

    @ApiOperation("获取区域中心首页数据统计")
    @GetMapping("/getAreaHomeStatistics")
    public ResultData<AreaHomeStatisticsVO> getAreaHomeStatistics() {
        return userService.getAreaHomeStatistics();
    }

    @ApiOperation("获取区域合伙人分页")
    @PostMapping("/getAreaPartnerPage")
    public ResultData<BasePageResp<AreaPartnerVO>> getAreaPartnerPage(@RequestBody AreaPartnerPageReq req) {
        return userService.getAreaPartnerPage(req);
    }

    @ApiOperation("获取我的团队数据统计")
    @GetMapping("/getMyGroupStatistics")
    public ResultData<MyGroupVO> getMyGroupStatistics(@AuthenticationPrincipal User user) {
        return userService.getMyGroupStatistics(user);
    }

    @ApiOperation("切换身份")
    @GetMapping("/switchIdentity")
    public BaseResp switchIdentity(@AuthenticationPrincipal User user, @RequestParam("type") Byte type) {
        return userService.switchIdentity(user, type);
    }

    @ApiOperation("变更老板上下级关系")
    @GetMapping("/changeBossRelationship")
    public BaseResp changeBossRelationship(@AuthenticationPrincipal User user, @RequestParam("inviteCode") String inviteCode) {
        return userService.changeBossRelationship(user, inviteCode);
    }

    @ApiOperation("测试生成音频")
    @GetMapping("/testAudioUrl")
    public String testAudioUrl() {
        return userService.testAudioUrl();
    }

    @ApiOperation("佣金转嗨币")
    @GetMapping("/changePointToCardPoint")
    public BaseResp changePointToCardPoint(@RequestParam("amount") BigDecimal amount) {
        return userService.changePointToCardPoint(amount);
    }

    @ApiOperation("获取我邀请首次购买记录统计")
    @GetMapping("/getMyInviteFirstBuyStatistics")
    public ResultData<InviteBuyStatisticsVO> getMyInviteFirstBuyStatistics() {
        return userService.getMyInviteFirstBuyStatistics();
    }

    @ApiOperation("嗨币转账")
    @PostMapping("/transferCardPoint")
    public BaseResp transferCardPoint(@RequestBody TransferCardPointReq req) {
        return userService.transferCardPoint(req);
    }

    @ApiOperation("获取我的赠送身份记录")
    @PostMapping("/getMyGiveIdentityRecordPage")
    public ResultData<BasePageResp<GiveIdentityRecordVO>> getMyGiveIdentityRecordPage(@RequestBody GiveIdentityRecordPageReq req) {
        return userService.getMyGiveIdentityRecordPage(req);
    }

    @ApiOperation("订阅秒杀活动")
    @PostMapping("/subscribeFlashSaleSpu")
    public BaseResp subscribeFlashSaleSpu(@RequestBody SubscribeRecord req) {
        return userService.subscribeFlashSaleSpu(req);
    }

    @ApiOperation("获取我的秒杀订阅分页")
    @PostMapping("/getMySubscribeRecordPage")
    public ResultData<BasePageResp<SubscribeRecordVO>> getMySubscribeRecordPage(@RequestBody SubscribeRecordPageReq req) {
        return userService.getMySubscribeRecordPage(req);
    }

    @ApiOperation("取消订阅秒杀活动")
    @GetMapping("/cancelSubscribeFlashSaleSpu")
    public BaseResp cancelSubscribeFlashSaleSpu(@RequestParam("id") Long id) {
        return userService.cancelSubscribeFlashSaleSpu(id);
    }

    @ApiOperation("获取我的收入变化")
    @GetMapping("/getMyIncomeChange")
    public ResultData<IncomeTimeVO> getMyIncomeChange(@AuthenticationPrincipal User user) {
        return userService.getMyIncomeChange(user);
    }

    @ApiOperation("编辑举报")
    @PostMapping("/editReport")
    public BaseResp editReport(@RequestBody Report report) {
        return userService.editReport(report);
    }


    @ApiOperation("获取活动补贴月详情")
    @PostMapping("/getStaticDividendDetail")
    public ResultData<StaticDividendDetailVO> getStaticDividendDetail(@RequestBody TimeRangeReq req) {
        return userService.getStaticDividendDetail(req);
    }

    @ApiOperation("获取活动补贴月详情")
    @PostMapping("/getMemberDividendDetail")
    public ResultData<StaticDividendDetailVO> getMemberDividendDetail(@RequestBody TimeRangeReq req) {
        return userService.getMemberDividendDetail(req);
    }

    @ApiOperation("获取活动补贴汇总")
    @PostMapping("/getTotalStaticDividend")
    public ResultData<SumStaticDividendVO> getTotalStaticDividend() {
        return userService.getTotalStaticDividend();
    }

    @ApiOperation("获取活动补贴订单分页")
    @PostMapping("/getStaticDividendOrderPage")
    public ResultData<BasePageResp<DividendOrderVO>> getStaticDividendOrderPage(@RequestBody TimeRangeReq req) {
        return userService.getStaticDividendOrderPage(req);
    }

    @ApiOperation("获取活动补贴人员分页")
    @PostMapping("/getStaticDividendMemberPage")
    public ResultData<BasePageResp<DividendMemberVO>> getStaticDividendMemberPage(@RequestBody TimeRangeReq req) {
        return userService.getStaticDividendMemberPage(req);
    }

    @ApiOperation("获取会员分红人员分页")
    @PostMapping("/getMemberDividendMemberPage")
    public ResultData<BasePageResp<DividendItemVO>> getMemberDividendMemberPage(@RequestBody DividendPageReq req) {
        return userService.getMemberDividendMemberPage(req);
    }

    @ApiOperation("获取所有人提现分页")
    @PostMapping("/getWithdrawPage")
    public ResultData<BasePageResp<WithdrawRespVO>> getWithdrawPage(@RequestBody PageReq req) {
        return userService.getWithdrawPage(req);
    }

    @ApiOperation("获取最新会员沉淀分红")
    @GetMapping("/getMemberDividendPrecipitationDetail")
    public ResultData<MemberPrecipitationVO> getMemberDividendPrecipitationDetail() {
        return userService.getMemberDividendPrecipitationDetail();
    }

    @ApiOperation("获取联合创始人月分红详情")
    @PostMapping("/getDirectorCommissionDetail")
    public ResultData<StaticDividendDetailVO> getDirectorCommissionDetail(@RequestBody TimeRangeReq req) {
        return userService.getDirectorCommissionDetail(req);
    }

    @ApiOperation("获取佣金发放记录分页")
    @PostMapping("/getUserCommissionPage")
    public ResultData<BasePageResp<UserCommissionResp>> getUserCommissionPage(@RequestBody UserCommissionReq req) {
        return userService.getUserCommissionPage(req);
    }


    @ApiOperation("获取提现排名")
    @PostMapping("/getWithdrawRankPage")
    public ResultData<BasePageResp<WithdrawRespVO>> getWithdrawRankPage(@RequestBody PageReq req) {
        return userService.getWithdrawRankPage(req);
    }

    @ApiOperation("获取所有人佣金分页")
    @PostMapping("/getAllCommissionPage")
    public ResultData<BasePageResp<UserCommissionResp>> getAllCommissionPage(@RequestBody UserCommissionReq req) {
        return userService.getAllCommissionPage(req);
    }

    @ApiOperation("获取所有用户分页")
    @PostMapping("/getAllUserPage")
    public ResultData<BasePageResp<UserDetailResp>> getAllUserPage(@RequestBody PageReq req) {
        return userService.getAllUserPage(req);
    }

    @ApiOperation("获取团队业绩分页")
    @PostMapping("/getGroupsPerformancePage")
    public ResultData<BasePageResp<GroupsPerformanceVO>> getGroupsPerformancePage(@RequestBody GroupsPerformancePageReq req) {
        return userService.getGroupsPerformancePage(req);
    }

    @ApiOperation("获取合伙人和分公司团队业绩记录分页")
    @PostMapping("/getShareholderPerformancePage")
    public ResultData<BasePageResp<ShareholderPerformanceVO>> getShareholderPerformancePage(@RequestBody ShareholderPerformancePageReq req) {
        return userService.getShareholderPerformancePage(req);
    }

    @ApiOperation("获取福利补贴分页")
    @PostMapping("/getWelfareFlowPage")
    public ResultData<BasePageResp<WelfareFlowVO>> getWelfareFlowPage(@RequestBody WelfareFlowPageReq req) {
        return userService.getWelfareFlowPage(req);
    }

    @ApiOperation("获取获取通用审批身份赠送分页")
    @PostMapping("/getTicketPage")
    public ResultData<BasePageResp<TicketVO>> getTicketPage(@RequestBody TicketPageReq req) {
        return userService.getTicketPage(req);
    }

    @ApiOperation("获取通用审批详情")
    @GetMapping("/getTicketDetail")
    public ResultData<TicketVO> getTicketDetail(@RequestParam("id") Long id) {
        return userService.getTicketDetail(id);
    }

    @ApiOperation("初审通用审批")
    @PostMapping("/firstAuditTicket")
    public BaseResp firstAuditTicket(@RequestBody Ticket req) {
        return userService.firstAuditTicket(req);
    }

    @ApiOperation("复审通用审批")
    @PostMapping("/secondAuditTicket")
    public BaseResp secondAuditTicket(@RequestBody Ticket req) {
        return userService.secondAuditTicket(req);
    }

    @ApiOperation("申请达人")
    @PostMapping("/applyCelebrity")
    public BaseResp applyCelebrity(@AuthenticationPrincipal User user) {
        BaseResp baseResp = new BaseResp();
        try {
            userService.applyCelebrity(user);
        } catch (ResultCodeException e) {
            baseResp.setResultCode(e.getResultCode());
        }
        return baseResp;
    }
}
